package com.xr.miniprogram.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xr.common.constant.StaffConstants;
import com.xr.common.constant.WorkStatusConstants;
import com.xr.miniprogram.domain.*;
import com.xr.miniprogram.domain.vo.MiniProgramServiceLogPageVO;
import com.xr.miniprogram.domain.vo.MiniProgramServiceLogVO;
import com.xr.miniprogram.mapper.MiniProgramServiceLogMapper;
import com.xr.miniprogram.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author da
 * @since 2023-09-28
 */
@Service
public class MiniProgramServiceLogServiceImpl extends ServiceImpl<MiniProgramServiceLogMapper, MiniProgramServiceLog> implements IMiniProgramServiceLogService {

    @Resource
    private IMiniProgramStaffService staffService;
    @Resource
    private IMiniProgramOrderUserService orderUserService;
    @Resource
    private IMiniProgramOrderService orderService;
    @Resource
    private IMiniProgramCommentService commentService;

    @Override
    public MiniProgramServiceLogPageVO getServiceLogPageVOByOrderUserId(Long orderUserId) {
        MiniProgramOrderUser orderUser = orderUserService.getById(orderUserId);
        MiniProgramServiceLog serviceLog = this.getById(orderUser.getServiceLogId());
        return new MiniProgramServiceLogPageVO(MiniProgramServiceLogVO.toMiniProgramServiceLogVO(serviceLog), staffService.getById(serviceLog.getStaffId()),
                orderUser, orderService.getById(orderUser.getOrderId()), commentService.getById(serviceLog.getMiniProgramCommentId()));
    }

    @Override
    public List<MiniProgramServiceLog> listByStaffId(Long staffId) {
        return this.list(new QueryWrapper<MiniProgramServiceLog>().lambda().eq(MiniProgramServiceLog::getStaffId, staffId));
    }
}
